import 'package:flutter/material.dart';

void main() {
  runApp(MaterialApp(
    home: HomeApp(),
    debugShowCheckedModeBanner: false,
  ));
}

class HomeApp extends StatelessWidget {
  const HomeApp({super.key});

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('Expanded 弹性布局'),
        leading: Icon(Icons.menu),
        backgroundColor: Colors.orange,
      ),
      body: ExpandedComp(),
      bottomNavigationBar: BottomNavigationBar(items: [
        BottomNavigationBarItem(
            icon: Icon(Icons.home), label: '首页', backgroundColor: Colors.red),
        BottomNavigationBarItem(
            icon: Icon(Icons.search), label: '搜索', backgroundColor: Colors.red),
        BottomNavigationBarItem(
            icon: Icon(Icons.person), label: '我的', backgroundColor: Colors.red)
      ]),
    );
  }
}

class ExpandedComp extends StatelessWidget {
  const ExpandedComp({super.key});

  @override
  Widget build(BuildContext context) {
    return Center(
      child: Container(
        width: 300.0,
        height: 200.0,
        padding: EdgeInsets.only(top: 10.0, bottom: 10.0),
        color: Colors.cyan,
        child: Column(
          spacing: 20,
          children: [
            Row(children: [
              Expanded(
                flex: 2,
                child: Container(
                  height: 80,
                  color: Colors.yellow,
                ),
              ),
              Expanded(
                flex: 1,
                child: Container(
                  height: 80,
                  color: Colors.green,
                ),
              ),
              Expanded(
                flex: 2,
                child: Container(
                  height: 80,
                  color: Colors.yellow,
                ),
              )
            ]),
            Row(children: [
              Expanded(
                child: Image.asset(
                  'open_eyes.png',
                  height: 80,
                ),
              ),
              Expanded(
                child: Text('茶水分离杯耐热隔热玻璃杯 茶水分离杯耐热隔热玻璃杯'),
              ),
            ]),
          ],
        ),
      ),
    );
  }
}
